#include "spk_camera.h"
#include "config.h"
#include "video.h"
#include "video_mpp.h" // VIDEO_MAX_SIZE
#include "audio.h"     // AUDIO_SIZE
#include "sip_client.h"
#include "device_scan.h"

#define LOG_TAG "spk_camera"
#define LOG_LVL LOG_LVL_INFO
#include "spk_ulog.h"

cls_spkcam::cls_spkcam(/* args */)
{
}

cls_spkcam::~cls_spkcam()
{
    delete cfg_src;
    delete cfg_cur;


    delete video;
    delete audio;
    delete sip_cli;

    delete device_scan;
}

void cls_spkcam::init_app()
{
    video_queue = create_msg_queue((char *)"/video_queue", 0, 64, VIDEO_MAX_SIZE + 2);
    audio_queue = create_msg_queue((char *)"/audio_queue", 0, 64, AUDIO_SIZE + 2);

    cfg_src = new device_info();
    init_file_decode("config.ini", cfg_src);
    cfg_cur = new device_info();
    memcpy(cfg_cur, cfg_src, sizeof(device_info));

    video = new cls_video(this);
    video->video_loop_start();
    audio = new cls_audio(this);
    audio->audio_loop_start();
    sip_cli = new cls_sip_client(this);
    if(cfg_cur->sip_server_connect)
    {
        sip_cli->sip_client_loop_start();
    }
    device_scan = new cls_device_scan(this); // 这个有点特殊, 建立之后就会自动新建自己的线程

}

// void cls_spkcam::video_start()
// {
//     video->video_loop_start();
// }

// void cls_spkcam::video_stop()
// {
//     video->video_loop_stop();
// }

// void cls_spkcam::audio_start()
// {
//     audio->audio_loop_start();
// }

// void cls_spkcam::audio_stop()
// {
//     audio->audio_loop_stop();
// }

// void cls_spkcam::sip_start()
// {
//     sip_cli->sip_client_loop_start();
// }

// void cls_spkcam::sip_stop()
// {
//     sip_cli->sip_client_loop_stop();
// }
